package util;

import java.sql.*;

public class DBUTil {
    private static String DRIVER="com.mysql.jdbc.Driver";
    private static String USER ="root";
    private static String URL="jdbc:mysql://127.0.0.1:3306/pest_control_sys";
    private static String PWD="lovo";
    static{
        try {
            Class.forName(DRIVER);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConn() throws SQLException {
        Connection conn =null;
        conn = DriverManager.getConnection(URL,USER,PWD);

        return conn;
    }
    public static void close(ResultSet rs, PreparedStatement ps,Connection conn){
        if(rs!=null){
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(ps!=null){
            try {
                ps.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(conn!=null){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}
